# 使用nginx作为基础镜像
FROM registry.cn-shanghai.aliyuncs.com/eian-images/nginx-brotli:stable-alpine

# 安装bash和envsubst工具
RUN apk add --no-cache bash gettext

# 创建工作目录
WORKDIR /usr/share/nginx/html

# 复制预构建的前端产物
COPY ./dist/ .

# 复制nginx配置模板
COPY ./deploy/nginx.conf /etc/nginx/nginx.conf.template
COPY ./deploy/docker-entrypoint.sh /

# 设置环境变量，默认后端API地址
ENV BACKEND_API_URL=http://127.0.0.1:8080

# 设置执行权限
RUN chmod +x /docker-entrypoint.sh

# 暴露80端口
EXPOSE 80

# 启动脚本
ENTRYPOINT ["/docker-entrypoint.sh"]
